<template>
  <div>
    <el-form label-width="80px" :inline="true">
      <el-form-item>
        <el-input
          @keydown.native.enter="search"
          suffix-icon="el-icon-search"
          v-model="keyword"
          placeholder="搜点什么..."
        ></el-input>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import PubSub from "pubsub-js";
export default {
  props: ["form"],
  data() {
    return {
      keyword: "",
    };
  },
  methods: {
    search(e) {
      e.preventDefault();
      this.axios
        .get(`${this.$reqPrefix}/searchByCourseName?course_name=${this.keyword}`)
        .then((res) => {
          // this.xxx = res.data.data;
          // 发布消息
          PubSub.publish("searchResult", res.data.data);
        });
      // 让keyword清空
      // this.keyword = "";
    },
  },
};
</script>

<style lang="less" scoped>
div {
  height: 100%;
  .el-form {
    height: 100%;
    // width: auto;
    display: flex;
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    .el-form-item {
      margin-right: 10px;
      margin-bottom: 0;
      display: flex;
      flex-direction: row;
      justify-content: center;
      align-items: center;
      &:nth-child(2) {
        margin-right: 50px;
      }
    }
  }
}
</style>